package com.shundr.auth.base;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.shundr.auth.R;
import com.shundr.auth.common.view.CListView;

/**
 * 基类 BaseListActivity
 * 
 * @author larry 2015-4-11 下午2:32:56
 * @version 1.0.0
 *
 */
public class BaseListActivity extends BaseActivity {

	protected Activity mContext;

	protected ActionBar mActionBar;
	protected TextView tvTitle;
	protected Button btnLeft;
	protected Button btnRight;

	protected CListView mListView;
	protected RelativeLayout mLayoutNoContent;
	protected TextView tvNoContent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.base_listview);
		mContext = this;
		initActionbar();
		mListView = (CListView) findViewById(R.id.lv_list);
		mLayoutNoContent = (RelativeLayout) findViewById(R.id.layout_no_content);
		tvNoContent = (TextView) findViewById(R.id.tv_no_content);
	}

	protected void initActionbar() {
		mActionBar = getSupportActionBar();
		mActionBar.setHomeButtonEnabled(true);
		mActionBar.setDisplayShowTitleEnabled(true);// 隐藏title

		mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
		mActionBar.setCustomView(R.layout.actionbar_main);
		tvTitle = (TextView) mActionBar.getCustomView().findViewById(
				R.id.tv_title);
		tvTitle.setText(getTitle());
		btnLeft = (Button) mActionBar.getCustomView().findViewById(
				R.id.btn_left);
		btnLeft.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
		btnRight = (Button) mActionBar.getCustomView().findViewById(
				R.id.btn_right);

		// 设置ActionBar的导航模式为List
		mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
		// 隐藏Home logo
		mActionBar.setDisplayShowHomeEnabled(true);
		View homeIcon = findViewById(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? android.R.id.home
				: R.id.abs__home);
		((View) homeIcon.getParent()).setVisibility(View.GONE);
		((View) homeIcon).setVisibility(View.GONE);
	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void startActivity(Intent intent) {

		super.startActivity(intent);
	}

	@Override
	public void finish() {

		super.finish();
	}

}
